package com.spider.queue;

import java.util.LinkedList;
import java.util.List;

public class Queue {

	private int count = 0;

	private List<String> articleList = new LinkedList<String>();

	public synchronized  void insertQueue(String articleUrl) {
		articleList.add(count, articleUrl);
		count++;
	}

	public synchronized  String outQueue() {
		count--;
		String articleUrl = articleList.get(0);
		articleList.remove(0);
		return articleUrl;
	}

	public  void intoQueue(String articleUrl) {
		articleList.add(count, articleUrl);
		count++;
	}

	public  String deQueue() {
		count--;
		String articleUrl = articleList.get(0);
		articleList.remove(0);
		return articleUrl;
	}

	public  boolean contains(String articleUrl) {
		return articleList.contains(articleUrl);
	}

	public  int size() {
		return articleList.size();
	}

	public  boolean isEmpty() {
		return articleList.isEmpty();
	}
}
